package com.qdlc.p2p.dal.model;

import org.springframework.beans.BeanUtils;

import com.qdlc.p2p.common.exception.BorrowException;
import com.qdlc.p2p.common.util.StringUtil;
import com.qdlc.p2p.dal.dto.BorrowAuto;
import com.qdlc.p2p.dal.dto.UserIdentify;
import com.qdlc.p2p.dal.util.UserUtils;

/**
 * 自动投标Model
 * 
 * @author xx
 * @version 2.0
 * @since 2014年3月21日
 */
public class BorrowAutoModel extends BorrowAuto {

	public static BorrowAutoModel instance(BorrowAuto auto) {
		BorrowAutoModel borrowAutoModel = new BorrowAutoModel();
		BeanUtils.copyProperties(auto, borrowAutoModel);
		return borrowAutoModel;
	}

	public BorrowAuto prototype() {
		BorrowAuto auto = new BorrowAuto();
		BeanUtils.copyProperties(this, auto);
		return auto;
	}
	
	public void validBorrowAutoOpen(UserIdentify userIdentify){
		String tppUserCustId = UserUtils.getUserTppCustId(userIdentify.getUserId());
		if (userIdentify.getRealNameStatus() != 1 || StringUtil.isBlank(tppUserCustId)) {
			throw new BorrowException("请先开通托管账户！","/member/security/setting.html","立即开户");
		}
	}

}
